<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="">
    <input type="text" name="" id="">
    <input type="button" name="" id="" onclick="loginHandler()">

    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.js"></script>
    <script src="./request.js"></script>
    <script>
        let loginAPI = '/users';
        async function loginHandler() {
            let ipts = document.querySelectorAll('input')
            let username = ipts[0].value;
            let password = ipts[1].value;
            let r = await http.get(loginAPI, { params: { username, password } })
            console.log(r.data.token);
            // 登录成功 存入token
            localStorage.setItem('shopToken', r.data.token)

        }
    </script>
</body>

</html>